<?php 
define('IN_WONDERSHARE', true);
header("Content-type:text/html;charset=utf-8");
ob_start("ob_gzhandler");
require('../includes/init.php');
require('./classes/control/control_product_parameters.php');


class ProductParameters
{
	var $product_parameters_c;
	
	function __construct(){
	
		$this->product_parameters_c = new ProductParametersControl();
		
	}
	
	//商品管理
	function index()
	{
		if($_REQUEST['act'] == 'edit')//修改
		{
			$p_parameters = array();
			$tile = '增加';
			
			if($_GET['is_add'] == 1 && !empty($_GET['product_id']))
			{
				$p_parameters = $this->product_parameters_c->get_product_parameters((int)$_GET['product_id']);
				$tile = '修改';
				$GLOBALS['smarty']->assign('p_parameters',     $p_parameters[0]);
			}
			
			if($_POST['sub_from'])
			{
				$affect = $this->product_parameters_c->update_product_parameters($_POST['product_id'],trim($_POST['guide_intro']),
				trim($_POST['guide_content']),trim($_POST['techspec_title1']),trim($_POST['techSpec_content_table1']),
				trim($_POST['techspec_title2']),trim($_POST['techSpec_content_table2']),$_POST['is_add']);
				
				if ($affect == 1) {
					
					echo  "<script type='text/javascript'> alert('".$_POST['tile']."成功！');
					window.location.href='/wondershare/product.php?action=productList'; </script>";
				}
			}
			$GLOBALS['smarty']->assign('product_id',     $_GET['product_id']);
			$GLOBALS['smarty']->assign('is_add',     $_GET['is_add']);
			$GLOBALS['smarty']->assign('form_act',     'edit');
			$GLOBALS['smarty']->assign('tile',     $tile);
			$GLOBALS['smarty']->display('product_parameters_info.htm'); 
		}
	}
	
	

}
$action    = $_REQUEST['action']; 
$product_parameters   = new ProductParameters;
if(method_exists($product_parameters, $action)) 
{
	$product_parameters->$action();
}else{
	$product_parameters->index();
}

?>
